var express = require('express');
var router = express.Router();

const songs = require("../data/songs")
// router.get('/', function (req, res, next) {
//   res.send('响应成功!')
// });

router.get('/all', function (req, res, next) {
	res.send({
		data: songs
	})
})


router.get('/search', function (req, res, next) {
  name = req.query.name
  
  info = songs.filter(ele => {
	  return ele['name'] === name
  })
  
  res.json({
	  "name": name,
	  "info": info
  })
});

router.get('/group', function(req, res, next){
	// get songs by singnerid
	group = req.query.group
	
	info = songs.filter(ele => {
		return ele['singner'] === group
	})
	res.json({
		  "data": info
	})
})

module.exports = router;
